<template>
  <div class="news_detail">
    <h3 class="tit">{{ newsInfo.title }}</h3>
    <div class="info">
      <span>发表时间：{{ newsInfo.add_time | formatDate }}</span>
      <span>点击次数：{{ newsInfo.click }}</span>
    </div>
    <div class="content" v-html="newsInfo.content"></div>
    <my-comment :artId="newId"> </my-comment>
  </div>
</template>

<script>
import Comment from '../subcomponents/Comment.vue'
export default {
  data() {
    return {
      newsInfo: {},
      newId: this.$route.params.id
    }
  },
  created() {
    this.getNewsDetail()
  },
  methods: {
    async getNewsDetail() {
      const { data: res } = await this.$http.get(
        '/api/getnew/' + this.$route.params.id
      )
      if (res.status !== 0) {
        return this.$toast('服务器异常!')
      }
      this.newsInfo = res.message[0]
    }
  },
  components: {
    'my-comment': Comment
  }
}
</script>

<style lang="less" scoped>
.news_detail {
  padding: 0 10px;
  .tit {
    color: #1989fa;
    font-size: 14px;
    text-align: center;
    line-height: 30px;
    margin: 0;
    padding: 5px 0;
  }
  .info {
    display: flex;
    -webkit-box-pack: justify;
    justify-content: space-between;
    font-size: 13px;
    color: #1989fa;
    border-bottom: 1px solid #ccc;
    padding: 7px 0;
  }
}
</style>
